import bentoml
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier

# Load data
iris = datasets.load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2)

# Train model
clf = RandomForestClassifier()
clf.fit(X_train, y_train)

# Save with BentoML
saved_model = bentoml.sklearn.save_model("iris_clf", clf)
print(f"Model saved: {saved_model.tag}")
print(f"Test accuracy: {clf.score(X_test, y_test):.4f}")

# Return the saved model tag for further processing
print(f"Model training completed. To update tags, use the model_tags.py module.")